package Hash;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        HashBucket bucket = new HashBucket();
        int t = 1;
        bucket.test(t);
        System.out.println(t);
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String right = in.next();
            String wrong = in.next();
            right = right.toUpperCase();
            wrong = wrong.toUpperCase();
            System.out.println(right);
            System.out.println(wrong);
            Set<Character> setW = new HashSet<>();
            for(char c:wrong.toCharArray()){
                setW.add(c);
            }
            Set<Character> setR = new HashSet<>();
            for(char c:right.toCharArray()){
                if(!setW.contains(c)&&!setR.contains(c)){
                    setR.add(c);
                    System.out.println(c);
                }
            }
        }
    }




    //依据单词出现次数与字典顺序 建立一个大小为K的小根对
    //首先用MAP统计单词的频次
    public List<String> topKFrequent(String[] words, int k) {
        Map<String, Integer> map = new HashMap<>();
        for (String word : words) {
            if (map.containsKey(word)) {
                int val = map.get(word);
                map.put(word, val + 1);
            } else {
                map.put(word, 1);
            }
        }

        PriorityQueue<Map.Entry<String, Integer>> minDeap = new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if (o1.getValue() == o2.getValue()) {
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        });
        int i = 0;
        for(Map.Entry<String,Integer> entry:map.entrySet()){

            if(i<k){
                minDeap.offer(entry);
                i++;
            }else {
                Map.Entry<String,Integer> top = minDeap.peek();
                if(entry.getValue().compareTo(top.getValue())>0){
                    minDeap.poll();
                    minDeap.offer(entry);
                }
                if(entry.getValue().compareTo(top.getValue()) == 0){
                    if(entry.getKey().compareTo(top.getKey())<0){
                        minDeap.poll();
                        minDeap.offer(entry);
                    }
                }
            }
        }
        ArrayList<String> list = new ArrayList<>();

        for (int j = 0; j < k; j++) {
            Map.Entry<String,Integer> tmp = minDeap.poll();
            list.add(tmp.getKey());
        }
        //e-2 f-3 a-5
        Collections.reverse(list);
        return list;
    }

// Definition for a Node.
class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }
}


    class Solution {
        public Node copyRandomList(Node head) {
            if(head == null){
                return null;
            }
            Map<Node,Node> map = new HashMap<>();
            Node cur = head;
            while (cur!=null){
                Node node = new Node(cur.val);
                map.put(cur,node);
            }
            for(Map.Entry<Node, Node> entry:map.entrySet()){
              entry.getValue().next = map.get(entry.getKey().next);
              entry.getValue().random = map.get(entry.getKey().random);
            }

            return map.get(head);

        }
    }
    public static void main0(String[] args) {
        HashBucket hashBucket = new HashBucket();
        hashBucket.put(1,1);
        hashBucket.put(2,12);
        hashBucket.put(3,2);
        hashBucket.put(4,3);
        hashBucket.put(5,14);
        hashBucket.put(6,6);
        hashBucket.put(7,7);
        hashBucket.put(8,5);
        hashBucket.put(9,5);



    }
}
